package test.file.writer;

import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;

public class FileWriterOutput {
	public static void log(String text, String filename) {
			
		FileOutputStream appendedFile = null;
		try {
			text = text + "\n";
			appendedFile = new FileOutputStream(filename, true);
			appendedFile.write(text.getBytes());
		} catch (FileNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (IOException e) {
			
			e.printStackTrace();
		} finally {
			try {
				if (appendedFile != null)
					appendedFile.close();
			} catch(IOException ioex) { 
				ioex.printStackTrace();
			}
		}
	}
	
	
	public static void main(String[] args) {
		FileWriterOutput.log("test1", "test.txt");
	}
}
